package com.liu.servlet;

import com.liu.entity.T_user;
import com.liu.service.user.T_userService;
import com.liu.service.user.T_userServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "AddServlet",urlPatterns = "/AddServlet")
public class AddServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doGet(request,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        T_userService service=new T_userServiceImpl();
//      account,  nick_name,  password,  gender,  id_card_no,  email,  phone

        String account=request.getParameter("account");
        String nick_name=request.getParameter("nick_name");
        String password=request.getParameter("password");
        Integer gender=Integer.valueOf(request.getParameter("gender"));
        String id_card_no=request.getParameter("id_card_no");
        String email=request.getParameter("email");
        String phone=request.getParameter("phone");
        T_user t_user=new T_user(null,account,nick_name,password,gender,id_card_no,email,phone,null,null);
        int ret=  service.add(t_user);
        if (ret==1)
        {
            System.out.println(12);
            request.getRequestDispatcher("client/Login.jsp").forward(request,response);
        }

    }
}
